<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>编辑关键词配置</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
            background-color: #f5f5f5;
        }
        .container {
            max-width: 600px;
            margin: 0 auto;
            background-color: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        h1 {
            color: #333;
            text-align: center;
        }
        .form-group {
            margin-bottom: 15px;
        }
        .form-group label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }
        .form-group input, .form-group select {
            width: 100%;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        .form-group input[type="checkbox"] {
            width: auto;
        }
        .btn {
            display: inline-block;
            padding: 10px 20px;
            margin: 5px;
            background-color: #007bff;
            color: white;
            text-decoration: none;
            border-radius: 4px;
            border: none;
            cursor: pointer;
        }
        .btn:hover {
            background-color: #0056b3;
        }
        .btn-secondary {
            background-color: #6c757d;
        }
        .btn-secondary:hover {
            background-color: #5a6268;
        }
        .message {
            padding: 10px;
            margin: 10px 0;
            border-radius: 4px;
        }
        .message.success {
            background-color: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }
        .message.error {
            background-color: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>编辑关键词配置</h1>
        
        {% with messages = get_flashed_messages(with_categories=true) %}
            {% if messages %}
                {% for category, message in messages %}
                    <div class="message {{ category }}">{{ message }}</div>
                {% endfor %}
            {% endif %}
        {% endwith %}
        
        <form method="POST">
            <input type="hidden" name="configId" value="{{ config.id }}">
            
            <div class="form-group">
                <label for="keyword">关键词:</label>
                <input type="text" id="keyword" name="keyword" value="{{ config.keyword }}" required>
            </div>
            
            <div class="form-group">
                <label for="count">收集数量:</label>
                <input type="number" id="count" name="count" value="{{ config.count }}" min="1" max="100" required>
            </div>
            
            <div class="form-group">
                <label for="platform">平台:</label>
                <select id="platform" name="platform">
                    <option value="douyin" {% if config.platform == 'douyin' %}selected{% endif %}>抖音</option>
                    <option value="tiktok" {% if config.platform == 'tiktok' %}selected{% endif %}>TikTok</option>
                </select>
            </div>
            
            <div class="form-group">
                <label for="source_lang">原语言:</label>
                <select id="source_lang" name="source_lang">
                    <option value="en" {% if config.source_lang == 'en' %}selected{% endif %}>英语</option>
                    <option value="zh" {% if config.source_lang == 'zh' or not config.source_lang %}selected{% endif %}>中文</option>
                    <option value="th" {% if config.source_lang == 'th' %}selected{% endif %}>泰语</option>
                    <option value="vi" {% if config.source_lang == 'vi' %}selected{% endif %}>越南语</option>
                </select>
            </div>
            
            <div class="form-group">
                <label for="target_lang">目标语言:</label>
                <select id="target_lang" name="target_lang">
                    <option value="vi" {% if config.target_lang == 'vi' or not config.target_lang %}selected{% endif %}>越南语</option>
                    <option value="th" {% if config.target_lang == 'th' %}selected{% endif %}>泰语</option>
                    <option value="pt-br" {% if config.target_lang == 'pt-br' %}selected{% endif %}>葡萄牙语-巴西</option>
                </select>
            </div>
            
            <div class="form-group">
                <label for="enabled">
                    <input type="checkbox" id="enabled" name="enabled" {% if config.enabled %}checked{% endif %}>
                    启用配置
                </label>
            </div>
            
            <div class="form-group">
                <button type="submit" class="btn">更新配置</button>
                <a href="/keyword-configs" class="btn btn-secondary">返回列表</a>
            </div>
        </form>
    </div>
</body>
</html>